package com.globagames.strategicgames.business
{
	import mx.messaging.Producer;
	import mx.messaging.events.MessageAckEvent;
	import mx.messaging.events.MessageFaultEvent;
	import mx.messaging.messages.AsyncMessage;
	import com.globagames.strategicgames.model.StrategicGameModelLocator;
	
	public class MessageProducer extends Producer
	{
		
		private var model:StrategicGameModelLocator = StrategicGameModelLocator.getInstance();
	
	
		public function MessageProducer()
		{
			destination = "battleMessages";
			subtopic = model.company.companyId + "_"+model.opponentCompany.companyId;
			addEventListener(MessageAckEvent.ACKNOWLEDGE, acknowledgeHandler);
			addEventListener(MessageFaultEvent.FAULT, faultHandler);
		}
		public function acknowledgeHandler(event:MessageAckEvent)
		{
			trace("acknowledgeHandler");
		}
		public function faultHandler(event:MessageFaultEvent)
		{
			trace("faultHandler");
		}
		public function sendMessage():void {
			var message:AsyncMessage = new AsyncMessage();
			message.body = model.player.name;
			send(message);
		}

	}
}